/* jshint esversion: 6 */
var path = require('path');
const { override, fixBabelImports, addWebpackAlias,overrideDevServer } = require('customize-cra');
const fs = require("fs");
const addProxy = () => (configFunction) => {
    configFunction.proxy = {
        '/api/': {
            target: 'http://localhost:8888',
            changeOrigin: true,
            pathRewrite: { '^/api': '/' },
        },
    };

    /**
     * const fs = require('fs');
    configFunction.https = {
        key: fs.readFileSync('6715530_app.neogenint.com.key', 'utf8'),
        cert: fs.readFileSync('6715530_app.neogenint.com.pem', 'utf8'),
        ca: fs.readFileSync('Digicert-OV-DV-root.cer', 'utf8')
    };**/

    return configFunction;
}
module.exports = {

  'webpack':  override(
                   fixBabelImports('import', {
                     libraryName: 'antd',
                     libraryDirectory: 'es',
                     style: 'css',
                   }),
                   // add an alias for "our" imports
                   addWebpackAlias({
                     '@iso/assets': path.resolve(__dirname, 'src/assets'),
                     '@iso/components': path.resolve(__dirname, 'src/components'),
                     '@iso/config': path.resolve(__dirname, 'src/config'),
                     '@iso/containers': path.resolve(__dirname, 'src/containers'),
                     '@iso/redux': path.resolve(__dirname, 'src/redux'),
                     '@iso/lib': path.resolve(__dirname, 'src/library'),
                     '@iso/ui': path.resolve(__dirname, 'src/UI'),
                   })
                   )
                   ,

  'devServer':overrideDevServer(
                      addProxy()
                  )


}

